package dyyx.web;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dyyx.util.MetricsUtil;

public class MetricsServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	public void init(ServletConfig config) throws ServletException{
		super.init(config);
		
	}

	
	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/plain; charset=utf-8");
		String str = MetricsUtil.getMetrics();
		response.getWriter().write(str);
	}
	
	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		doGet(request,response);
	}

	@Override
	public void destroy() {
		
		System.out.println(this.getClass().getSimpleName()+" destroy run "+System.currentTimeMillis());
        super.destroy();
	}
}